class Gun:
    def __init__(self, model):
        # 枪的种类
        self.model = model
        # 枪的子弹数
        self.buttle_num = 0
        #弹夹上限   被隐藏了，只能用接口访问
        self.__num=30

    def add_buttle(self, count):
        # 装子弹，上限为30
        if self.buttle_num < self.__num:
            self.buttle_num = self.__num
            count = self.buttle_num-count
            print(f"子弹已装填完毕，并且返还{count}个子弹")
        else:
            print("子弹已达上限，无法添加子弹")

    def shoot(self):
        if self.buttle_num <= 0:
            print("子弹已用尽")
            return
        else:
            self.buttle_num -= 1
            print("%s 发射子弹,剩余[%d]发子弹" % (self.model, self.buttle_num))

    def expanion(self):
        #安装扩容弹夹
        self.__num=60
        print("扩容弹夹已安装，现在装弹量为%d"%self.__num)


class Soldier():
    def __init__(self, name):
        # 士兵姓名
        self.name = name
        # 枪
        self.gun: Gun = None

    def fire(self):
        if self.gun is None:
            print(f"{self.name}还没有枪..")

        #  高喊口号
        print("冲啊...")

        # 射击
        self.gun.shoot()


ak47 = Gun("ak47")
ak47.expanion()
ak47.add_buttle(30)
zhangsan = Soldier("张三")
zhangsan.gun = ak47
zhangsan.fire()
